// pages/index3/index3.js
Page({
    
    /**
     * 组件的属性列表
     */
    properties: {
    },

    /**
     * 组件的初始数据
     */
    data: {
        scorename:'',
        term_id:"",
        terms: [{
            name: "2022-2023 第一学期",
            id: 2
        },
        {
            name: "2022-2023 第二学期",
            id: 3
        },  
    ],
    subs: null,
    cursubName: "请选择学科",
    list: null,
    header: null,
    },
    onLoad(){   
    },
    changes(e) {
        console.log(e.detail.selectId);
        console.log(e.detail.select);
        // process();
        this.setData({
            term_id:e.detail.selectId
        })
        var that =this
        wx.request({
            url: 'http://vz3q9q.natappfree.cc/getClassByTerm?term='+this.data.term_id,
            method: 'POST',
            data: {
                rnum: 2,
                username: 'test1'
            },
            header: {
                'content-type': 'application/x-www-form-urlencoded'
            },
            dataType: 'json',
            success(res) {
                console.log(res);
                console.log("初加载成功")
                that.setData({
                   subs:[{name: "苹果" ,id: 1},
                   {name: "西瓜" ,id: 2},
                   {name: "李子" ,id: 3},
                   {name: "梨" ,id: 4}
                  ],
                });
            }
        });
    },
    changes1(e) {
        console.log(e.detail.selectId);
        console.log(e.detail.select);
        // process();
        this.setData({
            scorename: e.detail.select,
        })
        var that =this
        wx.request({
            url: 'http://vz3q9q.natappfree.cc/getClassByTerm?term='+this.data.term_id,
            method: 'POST',
            data: {
                rnum: 2,
                username: 'test1'
            },
            header: {
                'content-type': 'application/x-www-form-urlencoded'
            },
            dataType: 'json',
            success(res) {
                console.log(res);
                console.log("初加载成功")
                that.setData({
                   subs:res
                });
            }
        });
    },
})
